<script type="text/javascript">
function disableagent(agentid,i)
{
	$("#updateagent"+i).html("<img src='../images/loadingmini.gif' />");
	$("#status"+i).html("<img src='../images/loadingmini.gif' />");
	$.ajax({
		url:"AgentControl.php",
		type:'get',
		data:"control=2&agentid="+agentid,
		cache: false,
		success: function(j){
		$("#updateagent"+i).html("<img src='../images/enable.gif' />");
		$("#status"+i).html("<b>Đang Bị Khóa</b>");
		location.reload();
	  	}
	});	
}
function activeagent(agentid,i)
{
	$("#updateagent"+i).html("<img src='../images/loadingmini.gif' />");
	$("#status"+i).html("<img src='../images/loadingmini.gif' />");
	$.ajax({
		url:"AgentControl.php",
		type:'get',
		data:"control=1&agentid="+agentid,
		cache: false,
		success: function(j){
		$("#updateagent"+i).html("<img src='../images/disable.gif' />");
		$("#status"+i).html("<b>Đang Hoạt Động</b>");
		location.reload();
	  	}
	});	
}
function getagentbalance(agent)
{
	
	$("#balance"+agent).html("<img src='../images/loading2.gif' />");
	if(agent=='ltd')
	{	
	$.ajax({
		url:"ltdbalance.php",
		type:'get',
		cache: false,
		success: function(j){
		$("#balance"+agent).html(j);
	  	}
	});	
	}
	else if(agent=='codesell')
	{	
	$.ajax({
		url:"codesellbalance.php",
		type:'get',
		cache: false,
		success: function(j){
		$("#balance"+agent).html(j);
	  	}
	});	
	}
}
</script>
<?php
$webroot="../";
include_once '../html/admintemplate.php';
?>
<table width="100%" border="1">
<tr class="classtopmenu">
<td>
Số Thứ Tự
</td>
<td>
Plan
</td>
<td>
Tên Agent
</td>
<td>
Tình Trạng
</td>
<td>
Balance
</td>
<td>
Điều Chỉnh
</td>
</tr>
<?php
$i=1;
foreach($GetAgent as $ShowAgent)
{
	$AgentId=$ShowAgent['id'];
	$Agent=$ShowAgent['agent_class'];
	if($ShowAgent['enable']=='Y')
	{
		$Status="<b>Đang Hoạt Động</b>";
		 
	}
	else 
	{
		$Status="<b>Đang Bị Khóa</b>";
		
	}
	?>
	<tr>
	<td>
	<?php echo $i;?>
	</td>
	<td>
	<?php echo $ShowAgent['agent_name'];?>
	</td>
	<td>
	<?php echo $ShowAgent['agent_class'];?>
	</td>
	<td id="status<?php echo $i;?>">
	<?php echo $Status; ?>
	</td>
	<td id="balance<?php echo $Agent;?>">
	<a href="javascript:getagentbalance('<?php echo $Agent;?>')" >Xem Balance</a>
	</td>
	<td id="updateagent<?php echo $i;?>">
	<?php if($ShowAgent['enable']=='Y')
	{
		
		?>
		<img onclick="javascript:disableagent(<?php echo $AgentId.','.$i; ?>)" src='../images/disable.gif' />
		<?php 
	}
	else 
	{

		?>
		<img onclick="javascript:activeagent(<?php echo $AgentId.','.$i; ?>)" src="../images/enable.gif" />
		<?php 
	}
	?>
	</td>
	</tr>
	<?php 
	$i++;
}
?>
</table>